#ifndef QVOLUMEANALYZER_H
#define QVOLUMEANALYZER_H

#include <QIODevice>
#include <QAudioFormat>
#include <QTime>

class QVolumeAnalyzer : public QIODevice
{
    Q_OBJECT
    Q_CLASSINFO("Author", "Sebastiano Galazzo")
    Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com")

public:
    QVolumeAnalyzer(const QAudioFormat &format, QObject *parent = 0);

    qint64 readData(char *data, qint64 maxlen);
    qint64 writeData(const char *data, qint64 maxlen);

    void start();
    void stop();

    int threshold;

signals:
    void thresholdExceeded(int);
    void clap();

public slots:
    
private:
    const QAudioFormat m_format;
    bool capturing;
    int exceeded;
};

#endif // QVOLUMEANALYZER_H
